{% extends 'common/goodspublic.html' %}
{% load static %}

{% block title %}
    支付
{% endblock %}

{% block header %}
    <header data-am-widget="header" class="am-header am-header-default sq-head ">
        <div class="am-header-left am-header-nav">
            <a href="javascript:history.back()" class="">
                <i class="am-icon-chevron-left"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="" class="">支付</a>
        </h1>
    </header>
{% endblock %}

{% block content %}
    <div style="height: 49px;"></div>
    <form method="post" action="">
        {% csrf_token %}
        <ul class="order-detail">
            <li><span>订单编号：</span>{{ order.number }}</li>
            <li><span>订单总价：</span>￥{{ order.pay_money }}</li>
        </ul>
        <ul class="pay-style">
            {% for payment in payments %}
                <li>
                    <img src="{{ MEDIA_URL }}{{ payment.logo }}" width="50"/>
                    <span>
		   	 		<p>{{ payment.name }}</p>
                        {% if payment.name == '支付宝' %}
                            <p class="descript">推荐有支付宝账号的用户使用</p>
                        {% endif %}
		   	 	</span>
                    <label class="am-radio-inline">
                        <input type="radio" {% if payment.name == '支付宝' %}checked="checked"{% endif %} name="payment_id"
                               value="{{ payment.pk }}" data-am-ucheck>
                        <input type="hidden" name="number" value="{{ order.number }}">
                    </label>
                </li>
            {% endfor %}
        </ul>
        <input type="button" class="login-btn" value="支付">
    </form>
{% endblock %}

{% block foot_js %}
    <script>
        $(function () {
            //点击事件
            $('.login-btn').on('click', function () {
                {#console.debug(111)#}
                //准备数据
                var data = $('form').serialize();
                console.debug(data);
                //发送请求
                $.ajax({
                    type: 'post',
                    url:"{% url 'orders:支付' %}",
                    data: data,
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 0) {
                            location.href = data.data
                        } else {
                            alert(data.errmsg)
                        }
                    }
                })
            })
        })
    </script>
    <script src="{% static 'js/jquery.min.js' %}"></script>
    <script src="{% static 'js/amazeui.min.js' %}"></script>
{% endblock %}

